package Chinese.Education.Identify.controller;

import Chinese.Education.Identify.pojo.Student;
import Chinese.Education.Identify.service.StudentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/student")
public class StudentController {
    @Resource
    private StudentService studentService;
    @RequestMapping(value = "/select" , method = RequestMethod.GET)
    public Map<String, Object> selectStudent(
            @RequestParam(value = "page",  defaultValue = "1")  int page,
            @RequestParam(value = "limit", defaultValue = "10") int limit,
            String school,
            String grade
    ) {
        Map<String, Object> stringObjectMap = studentService.selectStudent(page, limit, school, grade);
        return stringObjectMap;
    }
    @RequestMapping(value = "/insert" , method = RequestMethod.POST)
    public Map<String, Object> insert(@RequestBody Student student) {
        return studentService.insert(student);
    }
    @RequestMapping(value = "/update" , method = RequestMethod.POST)
    public Map<String, Object> update(@RequestBody Student student) {
        return studentService.update(student);
    }
    @RequestMapping(value = "/delete" , method = RequestMethod.POST)
    public Map<String, Object> delete(@RequestBody Student student) {
        return studentService.delete(student);
    }

}

